package com.tiancheng.trade.order.mapper;

import com.tiancheng.trade.order.model.IntOrder;
import com.tiancheng.trade.order.model.join.IntOrderJoin;
import com.tiancheng.trade.order.vo.app.OrderCenterQueryVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 英文版主订单持久化接口
 */
@Repository
public interface IntOrderMapper extends TYBaseMapper<IntOrder> {

    /**
     * 主订单退款次数
     * @param orderId
     * @param refundTimes
     * @return
     */
    @Update("update int_orders set refund_times = refund_times + #{refundTimes} where order_id = #{orderId}")
    int refund(@Param("orderId") String orderId, @Param("refundTimes") int refundTimes);

    /**
     * 根据流水号查询主订单及子订单信息
     * @param flowId
     * @return
     */
    List<IntOrderJoin> findWithSubByFlowId(@Param("flowId") String flowId);


    List<IntOrder> getCenterOrder(OrderCenterQueryVO queryVO);

    /**
     * 根据订单号查询主订单及子订单信息
     * @param orderId
     * @return
     */
    List<IntOrderJoin> findWithSubByOrderId(@Param("orderId")String orderId);

    String getOrderIdByFlowId(@Param("flowId")String flowId);
}